<?php

namespace Drupal\s_commerce_service\ViewsController;

use Drupal\s_commerce_service\ViewsController\handler\field\SCommerceServiceLineEditLinkViewsField;
use Drupal\s_commerce_service\ViewsController\handler\field\SCommerceServiceLineStatusViewsField;
use Drupal\s_commerce_service\ViewsController\handler\filter\SCommerceServiceLineStatusViewsFilter;
use EntityDefaultViewsController;


class SCommerceServiceLineViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $info = [];

      $info[$table]['edit_link'] = [
        'title' => t('编辑'),
        'help' => t('编辑.'),
        'field' => [
          'handler' => SCommerceServiceLineEditLinkViewsField::class,
        ],
      ];
      $info[$table]['status'] = [
        'title' => '状态 0 待审核 1 待退款 2 已完成 3 拒绝 4 待退货',
        'help' => '状态 0 待审核 1 待退款 2 已完成 3 拒绝 4 待退货',
        'real field' => 'status',
        'field' => [
          'handler' => SCommerceServiceLineStatusViewsField::class,
        ],
        'filter' => [
          'handler' => SCommerceServiceLineStatusViewsFilter::class,
        ],
      ];
      $data = drupal_array_merge_deep($data, $info);
    }
    return $data;
  }
}
